package cn.itcast.exception;

import cn.itcast.result.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalException {

    @ExceptionHandler(BusinessException.class)
    @ResponseBody
    public Object doBusinessException(BusinessException e){
        return Result.error(e.getCode(),e.getMessage());
    }
}
